package com.zhuangwei.spring;

import com.zhuangwei.spring.config.RootConfig;
import com.zhuangwei.spring.config.WebConfig;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;

/**
 * 定义DispatchServlet
 *
 * @author 文希
 * @create 2019-05-23 13:18
 **/
public class MyWebApplicationInitializer extends AbstractDispatcherServletInitializer {

    @Override
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }

    @Override
    protected WebApplicationContext createServletApplicationContext() {
        AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
        applicationContext.register(RootConfig.class);
        applicationContext.register(WebConfig.class);

        System.out.println("-------------------------------");
        return applicationContext;
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/*"};
    }


}
